import Cookies from 'js-cookie'

const TokenKey = 'ihrm-token'
const timeKey = 'ihrm-timeStamp'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// 处理token过期问题 - 登录的时候存一个时间戳 - 用token的时候当前时间戳 - 缓存时间戳是否大于一小时，大于一小时重新登陆

export function setTimeStamp() {
  return Cookies.set(timeKey, Date.now())
}

export function getTimeStamp() {
  return Cookies.get(timeKey)
}

export function removeTimeStamp() {
  return Cookies.remove(timeKey)
}
